@echo off
rem set p=%~f0.vbs
set p=%0
for /f "delims=" %%i in ("%p%") do set p=%%~ni
set p=%~dp0%p%.vbs
echo %p%
rem goto EXIT
echo,>%p%
echo 'HongShijin >>%p%
echo 'me@hongshijin.com >>%p%
echo '%date:~0,10% %time:~0,8% >>%p%
echo 'Batch change [AssemblyInfo.cs]'s [AssemblyVersion] and [AssemblyFileVersion] as now>>%p%
echo,>>%p%
echo Option Explicit >>%p%
echo,>>%p%
echo Const ForReading = 1 >>%p%
echo Const ForWriting = 2 >>%p%
echo,>>%p%
echo Function EachFolder (cd, folder) >>%p%
echo 	Dim d, t, f, s, r >>%p%
echo,>>%p%
echo 	For Each f In folder.Files >>%p%
echo 		If f.Name = "AssemblyInfo.cs" Then >>%p%
echo 			Set s = CreateObject("ADODB.Stream") >>%p%
echo 			s.Type = 2 >>%p%
echo 			s.Mode = 3 >>%p%
echo 			s.CharSet = "UTF-8" >>%p%
echo 			s.Open >>%p%
echo 			s.LoadFromFile f >>%p%
echo 			t = s.ReadText >>%p%
echo 			Set r = new RegExp >>%p%
echo 			r.Global = True >>%p%
echo 			r.IgnoreCase = True >>%p%
echo 			d = Now() >>%p%
echo 			r.Pattern = "(\[assembly:[\s]*AssemblyVersion\(""\d+)\.\d+\.\d+\.[\d\*]+(""\)\])" >>%p%
echo 			t = r.Replace(t, "$1." ^& Right("0" ^& (Year(d) Mod 100), 2) ^& "." ^& Month(d) ^& Right("0" ^& (Day(d) Mod 100), 2) ^& ".*$2") >>%p%
echo 			r.Pattern = "(\[assembly:[\s]*AssemblyFileVersion\("")\d+\.\d+\.\d+\.[\d\*]+(""\)\])" >>%p%
echo 			t = r.Replace(t, "$1" ^& (Year(d) Mod 100) ^& "." ^& Month(d) ^& "." ^& (Day(d) Mod 100) ^& "." ^& Hour(d) ^& Right("0" ^& (Minute(d) Mod 100), 2) ^& "$2") >>%p%
echo 			s.Position = 0 >>%p%
echo 			s.WriteText t >>%p%
echo 			s.SetEOS >>%p%
echo 			t = f.Path >>%p%
echo 			f.delete >>%p%
echo 			s.SaveToFile t >>%p%
echo 			s.Close >>%p%
echo 			EachFolder = Replace(Right(f, Len(f) - Len(cd) - 1), "\Properties\AssemblyInfo.cs", "") >>%p%
echo 			Exit Function >>%p%
echo 		End If >>%p%
echo 	Next >>%p%
echo,>>%p%
echo 	EachFolder = "" >>%p%
echo 	For Each f In folder.SubFolders >>%p%
echo 		t = EachFolder(cd, f) >>%p%
echo 		If t ^<^> "" And Len(t) ^> 1 Then EachFolder = EachFolder ^& VbCrLf ^& t >>%p%
echo 	Next >>%p%
echo End Function >>%p%
echo,>>%p%
echo Dim fso, vbs, cd, t >>%p%
echo IF WScript.Arguments.Count ^> 0 THEN >>%p%
echo 	t = WScript.Arguments(0) >>%p%
echo Else >>%p%
echo 	t = Wscript.ScriptFullName >>%p%
echo End IF >>%p%
echo If t = "" Then t = Wscript.ScriptFullName >>%p%
echo Set fso = CreateObject("Scripting.FileSystemObject") >>%p%
echo Set vbs = fso.GetFile(t) >>%p%
echo Set cd = vbs.ParentFolder >>%p%
echo t = EachFolder(cd, cd) >>%p%
echo Wscript.Echo t >>%p%
Cscript "%p%" "%~f0"
rem del %p%
:END
:EXIT
@echo on
@pause
